#include "fxcc/core/graph/opengl3/TextureCubeArrayJack.h"

fxcc::graph::opengl3::TextureCubeArrayJack::TextureCubeArrayJack(const fxcc::graph::common::TextureCubeArrayJack::Desc& desc)
	:fxcc::graph::opengl3::Texture(GL_TEXTURE_CUBE_MAP_ARRAY), fxcc::graph::common::TextureCubeArrayJack(desc)
{
	m_Available = Init();
}

bool fxcc::graph::opengl3::TextureCubeArrayJack::Init()
{
	m_Id = gliUtils2::create_texture(m_Desc.m_DDSPath.c_str());

	
	Bind();
	SetSampler(m_Desc.m_SamplerType);
	UnBind();


	{
		gli::texture texture = gli::load(m_Desc.m_DDSPath.c_str());
		auto Extent0 = texture.extent();
		auto layer = texture.layers();
		auto faces = texture.faces();

		auto fmt = texture.format();
		m_MipmapConfig.m_Width = Extent0.x;
		m_MipmapConfig.m_Height = Extent0.y;
		m_MipmapConfig.m_Depth = texture.layers();
		m_MipmapConfig.m_NrComponent = gli::component_count(fmt);
		m_MipmapConfig.m_HDR = gli::is_float(fmt);
	}
	return true;
}

